{extend name="index/iframe" /}

{block name="content"}
<div class="layui-tab layui-tab-brief box-pad">
    <ul class="layui-tab-title">
        <li class="layui-this">安卓包</li>
        <!--<li>苹果包</li>-->
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <ul class="box">
                <li>
                    <span class="span">游戏名称：</span>
                    <div class="box-r">{$find.game_name}（{$find.game_id}）</div>
                </li>
                <li>
                    <span class="span">游戏包名：</span>
                    <div class="box-r" id="package_name">{$find.package_name}</div>
                </li>
                <li>
                    <span class="span">游戏大小：</span>
                    <div class="box-r" id="package_size">{$find.package_size}</div>
                </li>
                <li>
                    <span class="span">游戏版本：</span>
                    <div class="box-r" id="version_str">{$find.version_str}</div>
                </li>
                <hr class="layui-bg-gray">
                <li>
                    <span class="span">上传母包：</span>
                    <div class="box-r" style="padding-top: 5px; overflow: auto; line-height: normal;">
                        <input type="hidden" value="{$Think.get.game_id}" id="game_id" name="game_id">
                        <div class="dropzone" id="upload" style="width: 100%;"></div>
                        <input type="hidden" name="file" id="file">
                    </div>
                </li>
            </ul>
        </div>
        <div class="layui-tab-item">暂未开放</div>
    </div>
</div>


{/block}

{block name="css"}
<link rel="stylesheet" type="text/css" href="__STATIC__/js/dropzone/dropzone.css">
<style>
    .box-pad {padding: 10px 20px;}
    .box {padding: 15px 20px;}
    .box li {display: block; overflow: hidden}
    .box .span {text-align:right; display: block; float:left; height: 34px; line-height: 34px; width: 9%;}
    .box .box-r{float: right;line-height: 34px; width: 90%;}
</style>
{/block}

{block name="js"}
<script src="__STATIC__/js/dropzone/jquery-2.0.3.min.js"></script>
<script src="__STATIC__/js/dropzone/dropzone.min.js"></script>
<script>
    Dropzone.autoDiscover = false;
    $("#upload").dropzone({
        url: '{:url("GameList/upload")}',
        paramName: 'file',
        maxFiles: 1,
        maxFilesize: 800, //MB,
        uploadMultiple: false, //是否一次提交多个文件
        dictCancelUpload: '上传中..',
        addRemoveLinks: true,
        dictRemoveFile: '删除',
        autoDiscover: false,
        dictDefaultMessage: '选择游戏包',
        dictMaxFilesExceeded: '最多只能上传一个文件',
        sending: function(file, xhr, formData) {
            xhr.setRequestHeader("game", $('#game_id').val());
        },
        success: function(file, jsonStr) {
            var json = $.parseJSON( jsonStr );

            if(json.code == 0){
                console.dir(json.data);
                $('#package_name').html(json.data.package_name);
                $('#package_size').html(json.data.package_size);
                $('#version_str').html(json.data.version_str);
                file.previewTemplate.appendChild(document.createTextNode('上传成功'));
            }else{
                file.previewTemplate.appendChild(document.createTextNode(json.msg));
            }
        }
    });

    layui.use(['form', 'laydate', 'element', 'upload'], function(){
        var form = layui.form
            ,$ = layui.$
            ,layer = layui.layer;
    });
</script>
{/block}